{% extends 'web/layout/manage.html' %}
{% load static %}
{% block title %}File{% endblock title %}
{% block css %}
<style>

    .panel-default{
        margin-top:10px;
    }
    .panel-default .panel-heading {
            display: flex;
            flex-direction: row;
            justify-content: space-between;
        }
    .panel-body{
        padding:0px;
    }

</style>
{% endblock css %}
{% block content %}

<!-- panel -->
<div class="container-fluid">    <!-- container-fluid -->
    <div class="panel panel-default">
        <div class="panel-heading">
            <div>
                <i class="fa fa-book" aria-hidden="true"></i> wiki文档
            </div>        
            <div>
                {% if wiki_editable %}
                    <a type="button" class="btn btn-warning btn-xs" href={% url 'web:wiki_edit' project_id=request.tracer.project.id wiki_id=wiki_obj.id %}>编辑</a>
                    <a type="button" class="btn btn-danger btn-xs" href={% url 'web:wiki_delete' project_id=request.tracer.project.id wiki_id=wiki_obj.id %}>删除</a>
                {% endif %}
                <a type="button" class="btn btn-success btn-xs" href={% url 'web:wiki_add' project_id=request.tracer.project.id %}>新建</a>
            </div>
            
        </div>
        <div class="panel-body">
            <div class="col-sm-3 title_list">


                <div class="list-group">
                    
                    <a href="#" class="list-group-item">Dapibus ac facilisis in</a>
                    <a href="#" class="list-group-item">Morbi leo risus</a>
                    <a href="#" class="list-group-item">Porta ac consectetur ac</a>
                    <a href={% url 'web:setting_delete' project_id=request.tracer.project.id %} class="list-group-item">删除项目</a>
                </div>
            </div>
            <div class="col-sm-9 content">
            {% if wiki_obj %}
               <!--  <H2><<{{wiki_obj.title}}>></h2> -->
                <div id="id_previewMarkdown">
                    <textarea>{{wiki_obj.content}}</textarea>
                </div>
            {% elif forms %}
                <form method="POST" novalidate>
                    {% csrf_token %}
                    <div>
                        {% for field in forms %}
                            {% if field.name == "content" %}
                                <div>
                                    <label for="{{field.id_for_label}}">{{field.label}}</label>
                                </div>
                                <div id="id_editor">
                                    {{field}}
                                </div>
                                <span class="error_msg">{{field.errors.0}}</span>
                            {% else %}

                                <div>
                                    <label for="{{field.id_for_label}}">{{field.label}}</label>
                                </div>
                                <div> 
                                    {{field}}
                                </div>
                                <span class="error_msg">{{field.errors.0}}</span>
                            {% endif %}
                        {% endfor %}
                        {% if forms.initial %}
                            <button type="submit" class="btn btn-primary">修  改</button>
                        {% else %}
                            <button type="submit" class="btn btn-primary">提  交</button>
                        {% endif %}
                    </div>
                </form>


            {% else %}
                <div id="id_previewMarkdown">
                <textarea>《{% if request.tracer.project %}{{request.tracer.project.name}}{% endif %}》wiki文档</textarea>
                </div>
                <a href={% url 'web:wiki_add' project_id=request.tracer.project.id %}>
                    <i class="fa fa-plus-circle" aria-hidden="true"></i>新建文档
                </a>
            {% endif %}
            </div>
        </div>
    </div>
<div>


{% endblock content %}
{% block js %}

<script>

</script>

{% endblock js %}